﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace echuCMS
{
    public partial class MDIMain : Form
    {
        private int childFormNumber = 0;

        public MDIMain()
        {
            InitializeComponent();
        }

        private void ShowNewForm(object sender, EventArgs e)
        {
            Form childForm = new Form();
            childForm.MdiParent = this;
            childForm.Text = "窗口 " + childFormNumber++;
            childForm.Show();
        }

        private void OpenFile(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();
            openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            openFileDialog.Filter = "文本文件(*.txt)|*.txt|所有文件(*.*)|*.*";
            if (openFileDialog.ShowDialog(this) == DialogResult.OK)
            {
                string FileName = openFileDialog.FileName;
            }
        }

        private void SaveAsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog();
            saveFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            saveFileDialog.Filter = "文本文件(*.txt)|*.txt|所有文件(*.*)|*.*";
            if (saveFileDialog.ShowDialog(this) == DialogResult.OK)
            {
                string FileName = saveFileDialog.FileName;
            }
        }

        private void ExitToolsStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void CutToolStripMenuItem_Click(object sender, EventArgs e)
        {
        }

        private void CopyToolStripMenuItem_Click(object sender, EventArgs e)
        {
        }

        private void PasteToolStripMenuItem_Click(object sender, EventArgs e)
        {
        }

        private void ToolBarToolStripMenuItem_Click(object sender, EventArgs e)
        {
            toolStrip.Visible = toolBarToolStripMenuItem.Checked;
        }

        private void StatusBarToolStripMenuItem_Click(object sender, EventArgs e)
        {
            statusStrip.Visible = statusBarToolStripMenuItem.Checked;
        }

        private void CascadeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.Cascade);
        }

        private void TileVerticalToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.TileVertical);
        }

        private void TileHorizontalToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.TileHorizontal);
        }

        private void ArrangeIconsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.ArrangeIcons);
        }

        private void CloseAllToolStripMenuItem_Click(object sender, EventArgs e)
        {
            foreach (Form childForm in MdiChildren)
            {
                childForm.Close();
            }
        }

        private void 客户维护ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //Form childForm = new Form();
            //childForm.MdiParent = this;

            FormCustomerMain fcm = new FormCustomerMain();
            fcm.MdiParent = this;
            fcm.Show();


        }

        private void MDIMain_Load(object sender, EventArgs e)
        {
            this.WindowState = FormWindowState.Maximized;
        }

        private void 业务员维护ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FormSalesMan fsal = new FormSalesMan();
            fsal.MdiParent = this;
            fsal.Show();
        }

        private void 客户分配ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form test = Application.OpenForms["FormCustomerPotential"];  //查找是否打开过about窗体 
            if ((test == null) || (test.IsDisposed)) //如果没有打开过
            {
                FormCustomerPotential formCustomerPotential = new FormCustomerPotential();
                formCustomerPotential.MdiParent = this;
                formCustomerPotential.WindowState = FormWindowState.Maximized;
                formCustomerPotential.Show();   //打开子窗体出来
            }
            else
            {
                test.Activate(); //如果已经打开过就让其获得焦点  
                test.WindowState = FormWindowState.Maximized;//使Form恢复正常窗体大小
            }

            //FormCustomerPotential formCustomerPotential = new FormCustomerPotential();
            //formCustomerPotential.MdiParent = this;
            //formCustomerPotential.Show();
        }

        private void 客户分配概况ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form test = Application.OpenForms["FormSalesMan_CustomerDetail"];  //查找是否打开过about窗体 
            if ((test == null) || (test.IsDisposed)) //如果没有打开过
            {
                FormSalesMan_CustomerDetail formSalesMan_CustomerDetail = new FormSalesMan_CustomerDetail();
                formSalesMan_CustomerDetail.MdiParent = this;
                formSalesMan_CustomerDetail.WindowState = FormWindowState.Maximized;
                formSalesMan_CustomerDetail.Show();   //打开子窗体出来
            }
            else
            {
                test.Activate(); //如果已经打开过就让其获得焦点  
                test.WindowState = FormWindowState.Maximized;//使Form恢复正常窗体大小
            }
        }

        private void 潜在客户审核ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form test = Application.OpenForms["FormCustomerApproach"];  //查找是否打开过about窗体 
            if ((test == null) || (test.IsDisposed)) //如果没有打开过
            {
                FormCustomerApproach formCustomerApproach = new FormCustomerApproach();
                formCustomerApproach.MdiParent = this;
                formCustomerApproach.WindowState = FormWindowState.Maximized;
                formCustomerApproach.Show();   //打开子窗体出来
            }
            else
            {
                test.Activate(); //如果已经打开过就让其获得焦点  
                test.WindowState = FormWindowState.Maximized;//使Form恢复正常窗体大小
            }
        }

        private void 区域负责人管理ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form test = Application.OpenForms["FormCityAdminManage"];  //查找是否打开过about窗体 
            if ((test == null) || (test.IsDisposed)) //如果没有打开过
            {
                FormCityAdminManage formCityAdminManage = new FormCityAdminManage();
                formCityAdminManage.MdiParent = this;
                formCityAdminManage.WindowState = FormWindowState.Maximized;
                formCityAdminManage.Show();   //打开子窗体出来
            }
            else
            {
                test.Activate(); //如果已经打开过就让其获得焦点  
                test.WindowState = FormWindowState.Maximized;//使Form恢复正常窗体大小
            }
        }

        private void 事业部维护ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form test = Application.OpenForms["FormOrganization"];  //查找是否打开过about窗体 
            if ((test == null) || (test.IsDisposed)) //如果没有打开过
            {
                FormOrganization formOrganization = new FormOrganization();
                formOrganization.MdiParent = this;
                formOrganization.WindowState = FormWindowState.Maximized;
                formOrganization.Show();   //打开子窗体出来
            }
            else
            {
                test.Activate(); //如果已经打开过就让其获得焦点  
                test.WindowState = FormWindowState.Maximized;//使Form恢复正常窗体大小
            }
        }
    }
}
